package com.example.androidwebpj.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

import java.io.IOException;

public class WebService  extends Service {

    private final static int  DEFAULT_PORT= 8080;
    private SimpleNanoService mNanoService;
    private String TAG = "WebService";


    @Override
    public void onCreate() {
        super.onCreate();
        mNanoService = new SimpleNanoService(DEFAULT_PORT);
        try {
            mNanoService.start();
            Log.d(TAG, "onCreate: mNanoService.start");
        } catch (IOException e) {
            e.printStackTrace();
            Log.d(TAG, "onCreate:  error:"+e.getMessage());
        }
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        mNanoService.stop();
        Log.d(TAG, "onCreate: mNanoService.stop");
    }
}
